#include <stdio.h>
#include <time.h>

#define NRA 500
#define NCA 500
#define NCB 500

double a[NRA][NCA];
double b[NCA][NCB];
double c[NRA][NCB];

int main( int argc, char *argv[] )
{
    int i, j, k;
    double start, calc, end;

    start = (double)clock() / (double)CLOCKS_PER_SEC;

    // Allocate array
    for( i=0; i<NRA; i++ )
        for( j=0; j<NCA; j++ )
            a[i][j]= i+j;
    for( i=0; i<NCA; i++ )
        for( j=0; j<NCB; j++ )
            b[i][j]= i*j;

    calc = (double)clock() / (double)CLOCKS_PER_SEC;

    // Calculate
    for ( k=0; k<NCB; k++ )
    {
        for ( i=0; i<NRA; i++ )
        {
            c[i][k] = 0.0;
            for ( j=0; j<NCA; j++ )
                c[i][k] += a[i][j] * b[j][k];
        }
    }

    end = (double)clock() / (double)CLOCKS_PER_SEC;

    // Report
    printf( "FILLING: %f\n", calc-start );
    printf( "CALCULATING: %f\n", end-calc );

}
